<template>
  <view>
    <u-popup mode='bottom' :show="showMainBusiness" @close="close" @touchmove.stop.prevent>
      <view style="width: 100%; height: 400px;">
        <view style="background-color: #cccccc;padding: 10px; margin-bottom: 10px;">
          <text>主营分类</text>
        </view>
        <view class="mainBu-content">
          <view class="mainBu-content-left">
            <scroll-view class="scroll-view-y" scroll-y="true">
              <view v-for="(item,index) in mainBusinessList" :key="item.category_id" @click="changeSide(item,index)"
                :class="[current==index ? 'active button' : 'button']">
                <text>{{item.category_name}}</text>
              </view>

            </scroll-view>
          </view>
          <view class="mainBu-content-right">
            <scroll-view class="scroll-view-y" scroll-y="true">
              <view :class="[item.selected ? 'choonse right-text' : 'right-text'] " v-for="item in mainGoodsSnList"
                :key="item.category_id" @click="changeGoodsSn(item)">
                <view style="border: 1px solid #cccccc;">{{item.category_name}}</view>
              </view>
            </scroll-view>
          </view>
        </view>
        <view class="butoon-bottom">
          <u-button type="warning" shape="circle" text='保存' @click="saveMainBu"></u-button>
        </view>
      </view>
    </u-popup>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        showMainBusiness: '',
        mainBusinessList: [],
        mainGoodsSnList: [],
      }

    },
    methods: {
      showMainBu() {
        this.showMainBusiness = true
      },
      close() {
        this.showMainBusiness = false
      },
      changeSide(item, index) {
        this.mainGoodsSnList = item.son
        this.current = index
      },
      changeGoodsSn(item) {
        item.selected = !item.selected
      },
      saveMainBu() {
        this.showMainBusiness = false
        this.showChangeMain(this.mainBusinessList)
      },
    }

  }
</script>

<style>
</style>